<template>
  <div>
    <el-table :data="fansList">
      <el-table-column>
        <template slot-scope="scope">
          <div class="f-list">
            <div>
              <el-tag type="danger" size="small" effect="plain">粉丝</el-tag>
              {{ scope.row.username }} 关注了你
            </div>
            <div>
              {{ scope.row.createTime }}
            </div>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev,pager,next"
      :total="count"
      :page-size="pageSize"
      :current-page="page"
      @current-change="changePage"
    >
    </el-pagination>
    <div ref="echart" id="echart"></div>
  </div>
</template>

<script>
  import * as echarts from "echarts";
export default {
  data() {
    return {
      fansList: [],
      page: 1,
      pageSize: 0,
      count: 0,
    };
  },
  methods: {
    getData() {
      this.$http({
        path: "/fans/list",
        method: "get",
        params: {
          params: {
            page: this.page,
            author: this.$store.state.user.username,
          },
        },
      }).then((res) => {
        if (res.code === 200) {
          this.fansList = res.data;
          this.count = res.fansCount;
          this.pageSize = res.fansCount;
          this.page = res.page;
        }
      });
    },
    changePage(p) {
      this.page = p;
      this.getData();
    },
  },
  created() {
    this.getData();
  },
  mounted() {
    var chartDom = this.$refs.echart;
    var myChart = echarts.init(chartDom);
    var option;
    option = {
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          data: [820, 932, 901, 934, 1290, 1330, 1320],
          type: "line",
          areaStyle: {},
        },
      ],
    };
    option && myChart.setOption(option);
  },
};
</script>

<style>
.f-list {
  display: flex;
  justify-content: space-between;
}
#echart {
  height: 500px;
}
</style>